Repository navigation
fix: record my own Discord profile at READY so a sending message keeps my avatar - #53
Conversation
|
@vbmithr this one fixes the avatar flicker from #46. What changed (
Tests (
Not covered:
This branch also carries the fix for a flaky macOS pacing test (#54), which was failing CI here. To try it: git fetch origin pull/53/head:pr-53 && git checkout pr-53
cargo test -p tinyclient --features gui gui::conversation::draw
cargo run -p tinyclient --features gui # starts chatd beside itIn a Discord channel where your earlier messages show your avatar (ideally a server where you have a per-server avatar), send a message. The sending row should show the same avatar from start to finish, with no generic icon. |
…s my avatar A message being sent names no picture, so its row shows the account's. On Discord that was missing: the account's picture is read from my own row in People, and READY and USER_UPDATE only set the account's name. READY now registers my picture and records my row before naming the account, and a USER_UPDATE of mine does the same, so the picture is there from connect and follows a change. The rail and chatd's own-picture fetch get it too. For a message of mine the window now shows its own picture, then the account's, and only then the one my newest message here was stored with, for a network that keeps no row of me. A stored picture is never re-read, so it no longer beats a newer account picture. The fake Discord counts fetches of my picture apart from what is asked of the API, since chatd fetches it on its own clock. Fixes #46 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7f6a9e5 to
c2d4662
Compare
|
Doesn’t seem to work here. |
Cause
A message being sent is built by
server.rs::new_messagewith no sender id or avatar. For an outgoing message with no avatar,gui/conversation/draw.rs::avatarused the account's picture (AccountStatus.avatar).Store::accountsreads that picture from the person row whose id is the account'sme, joined to that avatar's media row. On Discord that row was never written. READY called onlyctx.describe(name, me)(discord/ready.rs), and so didUSER_UPDATE(discord/events.rs), so the account picture was nearly alwaysNoneand the sending row showed the generic plate. The echo carriessender.avatar(avatar:{user}:{hash}, the global picture, fromdiscord/content.rs), so the real picture appeared once Discord answered.This PR used to say the earlier messages carry "a server-specific picture of me". That was wrong. chatd never produces one: Discord's
Memberhas no avatar field, and messages always carry the global avatar.Fix
chatd (
adapters/discord/ready.rs,events.rs)Discord::myself(user): registers my avatar media (ctx.media), records my own person row (ctx.people(&[user.person(None)])), then callsctx.describe. This is the sameUser::avatar/User::personpath used for relationships, DM recipients and member chunks. The row is written beforedescribe, so theChange::Statusit emits already has the picture.myself(&ready.user)instead ofdescribe.USER_UPDATEcalls it only when the user id is mine. Before, anyUSER_UPDATEoverwrote the account's name andme.blobs::own_pictures) downloads it from the CDN once per connect when it is not already on disk. Discord never triggered that fetch before.GUI (
gui/conversation/draw.rs)own_facenow picks, for any message of mine: the picture the message names, then the account picture, then (last resort) the picture on my newest message in the window. Stored messages keep the avatar id they were stored with, so a history picture no longer beats a newer account picture after I change mine.avatar:8:…. An emptymeskips the scan.said_by(the history searchwhoalready used) is unchanged from the earlier revision. Doc comments no longer mention a server-specific picture.Where I can now show up. My row has relation
none, so it is not in the People tab, the friend/request/blocked lists,owned,incoming, ortalked_to(I am never a DM peer). DM and group titles come from the recipients, not the person table, so they don't change. Member lists come from Discord's lists, which already include me. A people search or@completion with a query can now match me from the cache. That is already true on Telegram and Slack, which record my row, and on Discord, whose member search already recorded me when it matched. An@with no query still lists only owned people.Validation
New
my_picture_is_the_accounts_from_ready_and_follows_a_change_to_itincrates/chatd/tests/discord.rschecks that:avatar:1000:me0hash, and chatd fetches it with nothing asked by the shellUSER_UPDATEof mine with a new hash becomes the account pictureUSER_UPDATEchanges neither the account name nor its pictureWith the chatd change reverted, it fails with
left: ("Justin", None).The fake Discord counts fetches of my own picture apart from
requests, because chatd fetches it on its own 2 s clock. Without that, three tests that assert exact request lists or counts failed. The large-READY test now also asserts the picture is fetched exactly once in the first 30 s.GUI tests that replace the old circular ones:
mecargo test -p chatd --test discord: 32 passed, 0 failedcargo test -p chatd: 292 passed, 0 failed (all targets)cargo test -p tinyclient --features gui: 351 passed, 0 failed, 1 ignoredcargo clippy -p chatd -p tinyclient --features gui --all-targets: on this branch it stops at a deny-levelclippy::while_immutable_conditionindiscord/gateway.rs:488. That file is untouched here and identical onmain. With that one lint allowed, the run finishes with nothing in the touched files.Not checked
Fixes #46
🤖 Generated with Claude Code